package com.xiaoruyuan.firstday.domain.web;


public class BaseResponse {

    /**
     * 响应消息
     */
    private String message;
    /**
     * 错误码，0代表成功
     */
    private Integer error;
    /**
     * 返回数据
     */
    private Object data;


    public static BaseResponse success(Object data) {
        BaseResponse response = new BaseResponse();
        response.setError(ResponseConstants.SUCCESS);
        response.setMessage(ResponseConstants.SUCCESS_MESSAGE);
        response.setData(data);
        return response;
    }

    public static BaseResponse success(String message) {
        BaseResponse response = new BaseResponse();
        response.setError(ResponseConstants.SUCCESS);
        response.setMessage(message);

        return response;
    }
    public static BaseResponse error() {
        BaseResponse response = new BaseResponse();
        response.setError(ResponseConstants.ERROR);
        response.setMessage(ResponseConstants.DEFAULT_ERROR_MESSAGE);

        return response;
    }

    public static BaseResponse error(String message, Integer code) {
        BaseResponse response = new BaseResponse();
        response.setError(code);
        response.setMessage(message);

        return response;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getError() {
        return error;
    }

    public void setError(Integer error) {
        this.error = error;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
